Get Collection
Retrieve all documents from a specified collection to access and manage your unstructured data through the Hyperspell MCP server.
Instructions
Get a list of all documents in a collection
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection_name | Yes |
Implementation Reference
- src/hyperspell_mcp/server.py:106-110 (handler)The handler function for the 'Get Collection' tool. It lists all documents in the specified collection using the Hyperspell API and converts them to Document objects.@mcp.tool_or_resource("collection://{collection_name}", name="Get Collection") def get_documents(collection_name: str) -> list[Document]: """Get a list of all documents in a collection""" r = mcp.api.documents.list(collection=collection_name) return Document.from_pydantic(r.items)
- src/hyperspell_mcp/types.py:38-43 (schema)Pydantic-compatible dataclass defining the structure of Document objects returned by the 'Get Collection' tool.class Document(BaseModel): id: int title: str type: str summary: str
- src/hyperspell_mcp/server.py:71-85 (registration)Custom decorator method used to register the tool or resource for 'Get Collection' (and others), conditionally as tool or resource based on config.def tool_or_resource(self, uri: str, name: str | None = None): def decorator(fn: Callable): description = fn.__doc__ if self.config.use_resources: self.resource( uri, name=name, description=description, mime_type="application/json", )(fn) if self.config.use_tools: self.add_tool(fn, name=name, description=description) return fn return decorator